define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'auth/adminlog/index',
                    add_url: '',
                    edit_url: '',
                    del_url: 'auth/adminlog/del',
                    multi_url: 'auth/adminlog/multi',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                columns: [
                    [
                        //{field: 'state', checkbox: true },
                        {field: 'sort', title: '序号', operate: false},
                        //{field: 'admin_id', title: 'id', operate: false},
                        {field: 'admin.nickname', title: __('管理员姓名'), operate: false},
                        {field: 'title', title: __('操作'), operate: false},
                        //{field: 'url', title: __('Url'), align: 'left', formatter: Table.api.formatter.url},
                        {field: 'admin.mobile', title: __('管理员手机号'), operate: false},
                        {field: 'ip', title: __('IP'), operate: false},
                        //{field: 'browser', title: __('Browser'), operate: false, formatter: Controller.api.formatter.browser},
                        {field: 'createtime', title: __('登录登出时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}
                        //{field: 'operate', title: __('Operate'), table: table,
                        //    events: Table.api.events.operate,
                        //    buttons: [{
                        //            name: 'detail',
                        //            text: __('Detail'),
                        //            icon: 'fa fa-list',
                        //            classname: 'btn btn-info btn-xs btn-detail btn-dialog',
                        //            url: 'auth/adminlog/detail'
                        //        }],
                        //    formatter: Table.api.formatter.operate
                        //}
                    ]
                ],
                showToggle: false,
                showColumns: false,
                showExport: false,
                searchFormVisible: false,
                commonSearch: false,
                search:false,
                onLoadSuccess:function(){
                    // 这里就是数据渲染结束后的回调函数
                    $(".btn-editone").data("area", ["100%","100%"]);
                    $(".btn-refresh").hide();
                }
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
            formatter: {
                browser: function (value, row, index) {
                    return '<a class="btn btn-xs btn-browser">' + row.useragent.split(" ")[0] + '</a>';
                },
            },
        }
    };
    return Controller;
});